<style>
    .tabliv {
        display: none;
    }
   .tabliv > table{
       margin-left: 20px;
       background-color: #eeeeee;
   }
   .tabliv > table thead{
       background-color: #71C671;
   }

    .tabliv > table th, .tabliv > table td {
        padding: 8px;
        border-bottom: 1px solid #555;
    }
</style>

        <div class="container-fluid">
            <div class="wrapper">
                     <div class="panel" id="nav">
                    <div class="panel-heading"><h3 class="panel-title">装箱查询</h3></div>
                    <div class="panel-body">
                        <form action="__URL__/select_package_info"   method="get">
                            <div class="container-fluid">
                                <div class="col-sm-12 col-md-4  add-space">
                                    <div class="input-group input-group-md">
                                        <span class="input-group-addon">ShipmentId</span>
                                        <input class="form-control " placeholder="请输入内容" name="shipmentid"
                                               data-name-group="" type="text" value="{$_GET['shipmentid']}">
                                    </div>
                                </div>
                                <div class="col-md-2 add-space">
                                <input class="btn btn-primary jsSearchBtn" type="submit" value="搜索">
                            </div>


                                </div>
                        </form>
                        <div class="clearfix"></div>


                        <table class="table table-striped  table-hover" cellspacing="0" width="100%">
                            <thead>
                            <tr>
                                <th width="20"><input id="checkAll" type="checkbox"/></th>
                                <th width="30">序号</th>
                                <th width="30">&nbsp;</th>
                                <th>Shipmentid</th>
                                <th>账号</th>
                                <th>报关id</th>
                                <th>装箱编码</th>
                                <th>长(cm)</th>
                                <th>宽(cm)</th>
                                <th>高(cm)</th>
                                <th>重量(KG)</th>
                                <th>是否需要防火标示</th>
                                <th>是否出口退税</th>
                                <th>公司主体</th>
                                <th>创建人</th>
                                <th>创建时间</th>
                            </tr>
                            </thead>
                            <tbody>
                            <volist name="data" id="vo" key="num">
                                <tr>
                                    <td class="text-center"><input name="subBox" type="checkbox" value='{$vo.id}'/></td>
                                    <td>{$num}</td>
                                    <td id="tr{$vo.id}" class="plantr" style="color: #008b8b;cursor:pointer;">展开</td>
                                    <td>{$vo.shipmentid}</td>
                                    <td>{$vo.account_name}</td>
                                    <td>{$vo.customs_id}</td>
                                    <td>{$vo.package_code}</td>
                                    <td>{$vo.length}</td>
                                    <td>{$vo.width}</td>
                                    <td>{$vo.height}</td>
                                    <td>{$vo.weight}</td>
                                    <td><if condition="$vo.fire_alarm eq 1">是<else />否</if></td>
                                    <td><if condition="$vo.export_tax_rebate eq 1">是<else />否</if></td>
                                    <td>{$vo.enterprise_dominant}</td>
                                    <td>{$vo.adder_id}</td>
                                    <td>{$vo.create_time}</td>
                                </tr>
                                <tr>
                                    <td id="tr{$vo.id}s"  colspan="16" class="tabliv">
                                        <table>
                                            <thead>
                                            <tr>
                                                <th width="5%">sku编号</th>
                                                <th width="5%">seller_sku</th>
                                                <th width="10%">中文名称</th>
                                                <th width="5%">虚拟sku</th>
                                                <th width="19%">储位</th>
                                                <th width="5%">数量</th>
                                                <th width="5%">报关码</th>
                                                <th width="10%">sku申报要素</th>
                                                <th width="6%">sku品名</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                                <volist name="vo.packageDetail" id="val" key="number">
                                                    <tr>
                                                        <td>{$val.sku}</td>
                                                        <td>{$val.seller_sku}</td>
                                                        <td>{$val.sku_name}</td>
                                                        <td>{$val.sku_virtual}</td>
                                                        <td><p style="word-wrap: break-word;word-break : break-all; ">{$val.position}</p></td>
                                                        <td>{$val.quantity}</td>
                                                        <td>{$val.hs_code}</td>
                                                        <td>{$val.declaration_element}</td>

                                                        <td>{$val.sku_cname}</td>
                                                    </tr>
                                                </volist>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </td>
                                </tr>
                            </volist>
                            </tbody>
                        </table>
                        <div class="clearfix clear">

                            <div class="fixed-table-toolbar b10">
                                <if condition="$data">
                                <div id="toolbar" class="btn-group">
                                    <button type="button" class="btn btn-success" data-toggle="modal" data-target=".btn_ck">
                                        贴防火标示
                                    </button>
                                </div>
                                <div id="toolbar1" class="btn-group">
                                    <button type="button" class="btn btn-warning" onclick="download_box('{$data.0.shipmentid}')">下载</button>
                                </div>
                                <div id="toolbar3" class="btn-group">
                                    <button type="button" class="btn btn-danger" data-toggle="modal" data-target=".btn_ck2">
                                        删除
                                    </button>
                                </div>
                                <div id="toolbar2" class="btn-group">
                                    <button type="button" class="btn btn-warning" onclick="download_box_other('{$data.0.shipmentid}')">下载FBA拼箱拼板单</button>
                                </div>
                            </if>
                                <div id="toolbar4" class="btn-group">
                                    <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#btn_import">根据shipmentid导出装箱信息</button>
                                </div>
                            </div>


                        </div>

                    </div>
                </div>

            </div>
        </div>
    </div>

</div>
<div class="modal fade" id="btn_import">
    <div class="modal-dialog">

        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
                        class="sr-only">关闭</span></button>
                <h4 class="modal-title">导入文件<span style="color: red">（导入请使用xlsx类型的）</span></h4>
            </div>
            <form action="__URL__/upload_shipmentid" method="post" enctype="multipart/form-data" id="upSku">
                <div class="modal-body form-horizontal">
                    <div class="alert alert-info top20" role="alert">
                        <p>模板下载: <a href="javascript:void(0)" id="download" >点击这里下载模板</a></p></div>

                    <div class="form-group"><label class="col-md-3 control-label required">上传文件</label>

                        <div class="col-md-4"><input name="file" class="form-control" data-val="true"
                                                     data-val-required="请选择[上传文件]!" id="File" type="file" value="">
                        </div>
                    </div>

                    <div class="form-group">
                        <button id="submit-button" type="submit" class="col-md-offset-3 col-md-1 btn btn-danger">上传
                        </button>
                    </div>
                </div>
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            <button type="button" class="btn" data-dismiss="modal">取消</button>
        </div>
    </div>
</div>

<!---model 弹出页面----->

<!-- 推送对话框 -->
<div class="modal fade btn_ck">
    <div class="modal-dialog modal-sm">

        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
                        class="sr-only">关闭</span></button>
                <h4 class="modal-title">是否需要防火标示</h4>
            </div>
            <div class="modal-body"><p class="text-primary">你确定要贴防火标示？</p></div>

        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="doFire()">确定</button>
            <button type="button" class="btn" data-dismiss="modal">取消</button>
        </div>
    </div>
</div>
<div class="modal fade btn_ck2">
    <div class="modal-dialog modal-sm">

        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
                        class="sr-only">关闭</span></button>
                <h4 class="modal-title">是否需要删除</h4>
            </div>
            <div class="modal-body"><p class="text-primary">你确定要删除？</p></div>

        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="boxDel()">确定</button>
            <button type="button" class="btn" data-dismiss="modal">取消</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/javascripts/admin/layer/layer.js"></script>
<!-------------------------当前页面js引用处--------------------------------->
<script>
    /**
     * 展开
     */
    $(document).ready(function () {
        $(".plantr").click(function () {
            var trid = $(this).attr("id");
            if($(this).text()=='展开'){
                $(this).text('关闭');
                $(this).css('color','red')
            }else {
                $(this).text('展开');
                $(this).css('color','#008b8b')
            }
            //alert($(this).text());
            $("#" + trid + "s").toggle();

        });
    });
    /**
     * 粘贴防火标示
     * */
    function doFire() {
       var id = [];
       $("input:checkbox[name='subBox']:checked").each(function () {
           id.push($(this).val());
       });
        if(id==''){
            layer.msg('请选择需要贴防火标示的数据', {icon: 5});
            return false;
        }else {
            $.ajax({
                url: "__URL__/doFire",
                type: 'post',
                async: true, //default: true
                data: {'id':id},
                dataType: 'json', // default: Intelligent Guess (xml, json, script, or html)
                success: function (data, textStatus, jqXHR) {
                    //alert(data)
                    if (data == true) {
                        layer.msg('成功', {icon: 6});
                        window.location.href = window.location.href;
                    } else {
                        layer.msg('失败', {icon: 5});
                    }
                }
            });
        }
    }
    /**
     * 删除箱唛数据
     * */
    function boxDel() {
        var id = [];
        $("input:checkbox[name='subBox']").attr('checked',true);
        $("input:checkbox[name='subBox']:checked").each(function () {
            id.push($(this).val());
        });
        if(id==''){
            layer.msg('请选择需要删除的数据', {icon: 5});
            return false;
        }else {
            var shipmentid = $.trim($("input[name='shipmentid']").val());
            $.ajax({
                url: "__URL__/boxDel",
                type: 'post',
                async: true, //default: true
                data: {'id':id,'shipmentid':shipmentid},
                dataType: 'json', // default: Intelligent Guess (xml, json, script, or html)
                success: function (data, textStatus, jqXHR) {
                    //alert(data)
                    if (data == true) {
                        layer.msg('成功', {icon: 6});
                        window.location.href = window.location.href;
                    } else {
                        layer.msg(data, {icon: 5});
                    }
                }
            });
        }
    }
    function download_box(shipmentid) {
        var id = [];
        $("input:checkbox[name='subBox']:checked").each(function () {
            id.push($(this).val());
        });
        if(id==''){
            layer.msg('请选择需要下载的数据', {icon: 5});
            return false;
        }
        window.open("__URL__/download_box?id="+id+"&shipmentid="+shipmentid);
    }
    function download_box_other(shipmentid) {
        var id = [];
        $("input:checkbox[name='subBox']:checked").each(function () {
            id.push($(this).val());
        });
        if(id==''){
            layer.msg('请选择需要下载的数据', {icon: 5});
            return false;
        }
        window.open("__URL__/download_box_ther?id="+id+"&shipmentid="+shipmentid);
    }
    $("#download").click(function () {
        var fileName="FBA装箱信息导入模板";
        var list=new Array(["shipmentid"]);
        var list1= new Array(["FBAL46S72"]);
        window.location.href ="__URL__/skuDownload?"+"&fileName="+fileName+"&list="+list+"&list1="+list1;
    });

</script>